﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;

namespace Sunboxsoft.WinForm
{
    public interface IView
    {
        ViewHeader GetHeader();

        /// <summary>
        /// 注册动作
        /// </summary>
        /// <param name="collection"></param>
        void RegisterAction(ActionNodeCollection collection);

        void Active(ViewActiveArgs args);

        void Resume(ViewResumeArgs args);
    }

    public class ViewHeader
    {
        public string Title{get;private set;}
        public Image Image{get;private set;}
        public Image LargeImage{get;private set;}

        public ViewHeader(string title)
        {
            Title = title;
        }

        public ViewHeader(string title, Image image)
        {
            Title = title;
            Image = image;
        }

        public ViewHeader(string title, Image image, Image largeImage)
        {
            Title = title;
            Image = image;
            LargeImage = largeImage;
        }
    }

    public static class ViewExtension
    {
        public static void ShowMask(this IView view)
        {
            UIContext.Current.ViewManager.ShowMask(view, "loding...");
        }

        public static void ShowMask(this IView view, string text)
        {
            UIContext.Current.ViewManager.ShowMask(view, text);
        }

        public static void HideMask(this IView view)
        {
            UIContext.Current.ViewManager.HideMask(view);
        }

        public static void ShowAction(this IView view, string name, bool isShow)
        {
            UIContext.Current.ViewManager.ShowAction(view, name, isShow);
        }

        public static void EnableAction(this IView view, string name, bool isEnable)
        {
            UIContext.Current.ViewManager.EnableAction(view, name, isEnable);
        }
    }
}
